package chapter4.read

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

object Chapter4_3_3 extends App {
  val conf = new SparkConf().setMaster("local").setAppName(this.getClass.getSimpleName)
  val sc = new SparkContext(conf)

  //读取CSV格式的数据
  private val value: RDD[String] = sc.textFile("P:\\Project\\Idea\\bigdata\\spark\\src\\main\\resources\\data\\users.csv")
  private val inputCSVFile: Array[String] = value.flatMap(_.split(",")).collect
  inputCSVFile.foreach(println(_))

  // 读取TSV格式的数据
  private val inputTSVFile: Array[String] = sc.textFile("P:\\Project\\Idea\\bigdata\\spark\\src\\main\\resources\\data\\users.tsv").flatMap(_.split("\t")).collect
  inputTSVFile.foreach(println(_))

  sc.stop()

}
